package org.leetcode.easy;

import org.junit.Test;

public class TitleToNumber {
    private int titleToNumber(String columnTitle) {
        final int ADVANCE = 26;
        int sum = 0;
        int productAdvance = 1;
        for (int i = columnTitle.length() - 1; i >= 0; i--) {
            int number = columnTitle.charAt(i) - 64;
            int product = number *productAdvance;
            productAdvance *= ADVANCE;
            sum += product;
        }
        return sum;
    }
    @Test
    public void test(){
        System.out.println(titleToNumber("FXSHRXW"));
    }
}
